﻿namespace Hopfield.Simulator.WPF
{
    using System;
    using System.Collections.Generic;
    using System.Globalization;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Shapes;    

    /// <summary>
    /// Interaction logic for ExceptionWindow.xaml
    /// </summary>
    public partial class ExceptionWindow : Window
    {
        public ExceptionWindow()
        {
            this.InitializeComponent();
        }

        public ExceptionWindow(Exception ex) : this()
        {
            string text = string.Empty;
            Exception iex = ex;
            while (iex != null)
            {
                text += string.Format(CultureInfo.InvariantCulture,
                                      "{0}{1}{2}{3}{4}{5}",
                                      iex.GetType().ToString(),
                                      Environment.NewLine,
                                      iex.Message,
                                      Environment.NewLine,
                                      iex.StackTrace,
                                      Environment.NewLine);
                iex = iex.InnerException;
            }

            this.textBoxException.Text = text;
        }

        private void ButtonOK_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
